<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width"/>
<meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
<title>我(他)的关注</title>
<link rel="stylesheet" type="text/css" href="../../css/aui-flex.css" />
<link rel="stylesheet" type="text/css" href="../../css/aui.css" />
<link rel="stylesheet" type="text/css" href="../../css/common.css" />
<style>
.blank{
	height: 0.5rem;
	background: #F5F7F8;
}
.infoBox{
	padding: 0 0.6rem;
}
.icon{
	/*width: 2rem;*/
	height: 2rem;
	border-radius: 50%;
	margin-right: 0.35rem;
}
.info{
	/*height: 3.3rem;*/
	padding: 0.7rem 0;
}
.color-36{
	color: #363335;
}
.follow{
	width: 2.4rem;
	height: 1.1rem;
	line-height: 1rem;
	text-align: center;
	font-size: 0.6rem;
	border: 1px solid #E73250;
	color: #E73250;
	border-radius: 5rem;
}
.dis{
	opacity: 0.6;
border: 1px solid #ADADAD;
color: #adadad;
}
</style>
</head>
<body>
	<div class="notData aui-hide aui-flex-row aui-flex-middle">
		<img src="../../image/notdata/07.png" class="notImg" alt="">
		<div class="color-ad aui-font-size-14 txt">还没有关注</div>
	</div>
<div class="blank"></div>
<div class="bg-white infoBox">
	<div id="list_html">

	</div>
<script type="text/x-dot-template" id="list_tpl">
{{ for(var i in it) { }}
	<div class="info aui-flex-col aui-flex-between aui-flex-middle aui-border-b" data-id="{{=it[i].attention_id}}" data-user="{{=it[i].userid}}">
		<div tapmode onclick="openItHome(this)"><img class="icon" src="{{=it[i].user_avatar}}" alt=""></div>
		<div class="flex-auto">
			<div class="aui-font-size-14 color-36">{{=it[i].user_nickname}}</div>
			<div class="aui-font-size-12 color-ad"></div>
		</div>
		<div class="follow dis" tapmode onclick="onFollow(this)">已关注</div>
	</div>
{{}}}
</script>
</div>
</body>
<script type="text/javascript" src="../../script/import.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
var userId;
apiready = function(){
	api.parseTapmode();
	userId = api.pageParam.visitorId;
	if(userId == getUserId()){
		userId = getUserId();
	}
	getfollowList();
};
function getfollowList(){
	api.ajax({
		url: BASE_URL + 'App/Article/userAttention',
		method: 'post',
		data: {
			values: {
				userid: userId,
				type: 1,
			}
		}
	},function(ret, err){
		if (ret) {
			if(ret.code == 1){
				$$('.notData').addClass('aui-hide');
				var tpl = $$('#list_tpl').html();
				var tempFn = doT.template(tpl);
				var list_data = ret.data;
				$$('#list_html').html(tempFn(list_data));
				api.parseTapmode();
		}else{
			$$('#list_html').html('');
			$$('.notData').removeClass('aui-hide');
		}
	}
	});
}
function openItHome(el){
	var _this = $$(el);
	var item = _this.parents('.info');
	var itemId = item.data('user');
	api.execScript({
	    name: 'article_win',
	    frameName: 'article_frm',
	    script: 'closeWin();'
	});
	setTimeout(function(){
		api.openWin({
		    name: 'article_win',
		    url: 'article_win.html',
		    pageParam: {
		        itemId: itemId
		    }
		},2000);
	})

}
function onFollow(el){
	var _this = $$(el);
	var item = _this.parents('.info');
	var itemId = item.data('user');
	var confirmMaskTxt = ['是否取消关注？','取消','确认'];
	openConfirmMask(confirmMaskTxt,'queren('+itemId+')');
}
function queren(id){
		api.ajax({
			url: BASE_URL + 'App/Article/userFollow',
			method: 'post',
			data: {
				values: {
					userid: getUserId(),
					concerned_userid: id
				}
			}
		},function(ret, err){
			if (ret) {
				if(ret.code == 1){
					toast(ret.msg);
					getfollowList();
					api.execScript({
 				     name: 'article_win',
 				     frameName: 'article_frm',
 				     script: 'getMyPage();'
 				 });
				}else{
					toast(ret.msg);
				}
			}
		});
}
function closeWin(){
	api.closeWin();
}
</script>
</html>
